﻿using System;
using System.Web.Mvc;
using System.Web.Security;
using FinancePortal.Business.Repository;
using FinancePortal.Domain.Enum;
using Microsoft.Practices.Unity;

namespace FinancePortal.Business.Infraestructure
{
    public class AccountRoleProvider : RoleProvider
    {
        //private readonly IResourceRepository _resourceRepository;

        //public AccountRoleProvider()
        //    : this(DependencyResolver.Current.GetService<IResourceRepository>())
        //{ }

        //public AccountRoleProvider(IResourceRepository resourceRepository)
        //    : base()
        //{
        //    _resourceRepository = resourceRepository;
        //}

        [Dependency]
        public IResourceRepository ResourceRepository { get; set; }

        #region Ununsed Overrides

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }

        #endregion

        public override string[] GetRolesForUser(string username)
        {
            var profile = Enum.GetName(typeof(Profile), ResourceRepository.GetBySOEID(username).Profile);
            return new[] { profile };
            //return new[] { "Administrator" };
        }
    }
}
